import request from '@/utils/request/req';

// 企业微信连接列表接口参数类型
export interface ConnectWeChatListParams {
  userName?: string; // 用户昵称
  userOpenId?: string; // 微信id
}

// 企业微信连接列表项类型
export interface ConnectWeChatListItem {
  id: number;
  accountType: string;
  userOpenId: string;
  userWechatUserId: string | null;
  userName: string;
  userAvatarUrl: string;
  userEmail: string | null;
  userPhone: string | null;
  accountCreateTime: string | null;
  accountInfoUpdateTime: string | null;
  accountStatus: string;
}

// 更新企业微信连接参数类型
export interface UpdateConnectWeChatParams {
  id: string;
  userName: string;
  userWechatUserId: string;
  userEmail: string;
  userPhone: string;
  accountStatus: string;
  wxId: string;
}

// 获取企业微信连接列表
export function getConnectWeChatList(params: ConnectWeChatListParams) {
  return request<ConnectWeChatListItem[]>({
    url: '/enterprise/connectWeChatList',
    method: 'get',
    params
  });
}

// 更新企业微信连接
export function updateConnectWeChat(data: UpdateConnectWeChatParams) {
  return request({
    url: '/enterprise/updateConnectWeChat',
    method: 'post',
    data
  });
}
